﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.ServiceModel;

namespace ZgOffice.WindowsServiceHost
{
    public partial class ZGOfficeService : ServiceBase
    {
        ServiceHost host = null;
        public ZGOfficeService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            WSDualHttpBinding bind = new WSDualHttpBinding();
            Uri baseAddress = new Uri("http://127.0.0.1:6549/Service");
            host = new ServiceHost(typeof(ZgOffice.Services.OfficeService), baseAddress);
            host.AddServiceEndpoint(typeof(ZgOffice.IServices.IOfficeService), bind, "");
            host.Open();
        }

        protected override void OnStop()
        {
            if (host != null)
            {
                host.Close();
                host = null;
            }
        }
    }
}
